<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>渲染图片案例</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    li {
      list-style: none;
    }

    .box {
      display: flex;
      flex-wrap: wrap;
      width: 540px;
      margin: 20px auto;
    }



    .box li {
      width: 100px;
      height: 100px;
      margin: 0 10px 10px 0;
    }

    .box li:nth-child(5n+1) {
      margin-right: 0;
    }

    .box li img {
      width: 100%;
      height: 100%;
      border: 2px solid #258DF2;
      border-radius: 10px 0 10px 0;
    }
  </style>
</head>
<body>
    <ul class="box">
        <script>
            /*###  核心练习题
        
            需求：
        
            根据用户输入的个数，页面可以渲染对应王者荣耀永雄的个数
        
            效果如下：
        
            <img src="assets/222.gif">
        
            思路分析：
        
            1. 渲染图片比较多，我们可以把图片地址放入数组中，
            2. 图片名称是有序号排列的，比如1.webp  2.webp 此处可以使用循环方式重复渲染图片
            3. 渲染位置？ 可以考虑放到 box盒子里写script 即可 */
        
            let arr = [
            './images/1.webp',
            './images/2.webp',
            './images/3.webp',
            './images/4.webp',
            './images/5.webp',
            './images/6.webp',
            './images/7.webp',
            './images/8.webp',
            './images/9.webp',
            './images/10.webp',
            './images/11.webp',
            './images/12.webp',
            './images/13.webp',
            './images/14.webp',
            './images/15.webp',
            './images/16.webp',
            './images/17.webp',
            './images/18.webp',
            './images/19.webp',
            './images/20.webp'
        ]
        let num = prompt('请输入显示的英雄个数1~20之间：')
        for (let i = 0; i < num; i++) {
            document.write(`
            <li>
                <img src="${arr[i]}" alt="">
            </li>
            `)
        }
        </script>
    </ul>

</body>
</html>